aboutsummaryrefslogtreecommitdiff
path: root/src/app/(main)/websites/[websiteId]/cohorts/CohortsDataTable.tsx
blob: 6734384e3102bf67bbf36eb397db4365290d0ebb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { DataGrid } from '@/components/common/DataGrid';
import { useWebsiteCohortsQuery } from '@/components/hooks';
import { CohortAddButton } from './CohortAddButton';
import { CohortsTable } from './CohortsTable';

export function CohortsDataTable({ websiteId }: { websiteId?: string }) {
  const query = useWebsiteCohortsQuery(websiteId, { type: 'cohort' });

  const renderActions = () => {
    return <CohortAddButton websiteId={websiteId} />;
  };

  return (
    <DataGrid
      query={query}
      allowSearch={true}
      autoFocus={false}
      allowPaging={true}
      renderActions={renderActions}
    >
      {({ data }) => <CohortsTable data={data} />}
    </DataGrid>
  );
}